home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- *
- * ADOBE CONFIDENTIAL
- * ___________________
- *
- * Copyright 2000 Adobe Systems Incorporated
- * All Rights Reserved.
- *
- * NOTICE: All information contained herein is, and remains the property of
- * Adobe Systems Incorporated and its suppliers, if any. The intellectual
- * and technical concepts contained herein are proprietary to Adobe Systems
- * Incorporated a nd its suppliers and may be covered by U. S. and Foreign
- * Patents,patents in process,and are protected by trade secret or copyright
- * law. Dissemination of this information or reproduction of this material
- * is strictly forbidden unless prior written permission is obtained from
- * Adobe Systems Incorporated.
- *
- **************************************************************************/
-
- /* ----------------------------------------------------------------
- // JSA.h
- // Definitions for the GoLive Extend Script SDK
- // -------------------------------------------------------------- */
-
- #ifndef _JSA_H_
- #define _JSA_H_
-
- /* The JSA Javascript Interface
- The JSA interface permits developers to write binary code extensions for the Extend Script SDK.
- All modules must reside in the SDK subdirectory Common, and all functions are callable by all
- Javascript extension modules. The functions are accessible as parts of a Javscript object
- which has the same name as the DLL or SharedLib. If, for example, the DLL is called "SomeExt.DLL",
- and it contains a function "foo", the function is callable as "SomeExt.foo()".
-
- See the documentation for further information.
-
- When writing a module, it is important to implement the macro JSA_INIT once which defines some data
- structures and performs the necessary initialization of the module.
- */
-
- #ifdef __cplusplus
-
- extern "C" {
- #endif
-
- /**
- All data elements are opaque void pointers which are casted internally.
- */
-
- typedef void *JSValue;
-
- /**
- The supplied data is one of the following scalar types, returned by JSAGetValueType().
- */
-
- enum JSAValueType {
- /** Undefined or empty value. */
- JSA_UNDEFINED,
- /** A boolean value,either 0 or 1. */
- JSA_BOOL,
- /** A 32 bit signed integer quantity. */
- JSA_INTEGER,
- /** An 8 byte double precision floating point value. */
- JSA_DOUBLE,
- /** A null-terminated ASCII string. */
- JSA_STRING
- };
-
- /**
- All callable functions must be encoded as JSANativeMethods. They receive
- an argc/argv combination as well as a location to store the return value.
- @param argc the number of arguments
- @param argv the argument vector
- @param retval a location to store any return value, preset to undefined
- */
- typedef void (*JSANativeMethod)(int argc, JSValue *argv, JSValue returnValue);
-
- typedef int (*JSAValueTypeFct)(void *, JSValue);
- typedef long (*JSAValueToIntFct)(void *, JSValue);
- typedef void (*JSAIntToValueFct)(void *, long, JSValue);
- typedef int (*JSAValueToBoolFct)(void *, JSValue);
- typedef void (*JSABoolToValueFct)(void *, int, JSValue);
- typedef char* (*JSAValueToStringFct)(void *, JSValue);
- typedef void (*JSAStringToValueFct)(void *, char *, JSValue);
- typedef double (*JSAValueToDoubleFct)(void *, JSValue);
- typedef void (*JSADoubleToValueFct)(void *, double, JSValue);
- typedef void (*JSARegisterFunctionFct)(void *, char *name, JSANativeMethod);
- typedef void (*JSASetErrorFct)(void *, char*);
- typedef void (*JSAInitializeFct)(void *);
- typedef void (*JSAExitFct)();
- typedef void (*JSAUndefinedToValueFct)(void *, JSValue);
- typedef void (*JSAEvalFct)(void*, char* text, JSValue retVal, long timeout);
-
- #ifdef WIN32
- #define JSAEXPORT __declspec(dllexport)
- #else
- #define JSAEXPORT
- #endif
-
- /* ---------- Environment --------------------- */
-
- typedef struct _JSAEnv
- {
- long jsaStructSize;
- long jsaVersion;
- void * jsaInst;
- void * externalRef;
- JSAValueTypeFct vtypFct;
- JSAValueToIntFct vtoiFct;
- JSAIntToValueFct itovFct;
- JSAValueToBoolFct vtobFct;
- JSABoolToValueFct btovFct;
- JSAValueToStringFct vtosFct;
- JSAStringToValueFct stovFct;
- JSAValueToDoubleFct vtodFct;
- JSADoubleToValueFct dtovFct;
- JSARegisterFunctionFct regFct;
- JSASetErrorFct errFct;
- JSAUndefinedToValueFct utovFct;
- JSAEvalFct evalFct;
- } JSAEnv;
-
- /* ---------- Interface ------------------------- */
-
- /**
- The JSAMain function is called from within the JSA_INIT macro. It should be used
- to register all functions callable by the Extend Script SDK. It is called when the
- module has been loaded, which the SDK does on demand before calling the first
- function inside the module.
- */
- extern void JSAEXPORT JSAMain(void);
-
- /**
- The JSAExit function is called when the extension module is about to be unloaded.
- Here, the module may be deinitialized.
- */
- extern void JSAEXPORT JSAExit(void);
-
- /**
- Retrieve the type of a value. It is one of the JSAValueType enums.
- @param v the JSAValue to check
- @return the type of the value
- */
- #define JSAGetValueType(v) JSAEnvObj->vtypFct(JSAEnvObj,v)
-
- /**
- Retrieve the value as a signed 32 bit integer quantity. Automatic conversion
- to the value is applied according to Javascript rules if necessary.
- @param v the JSAValue to convert
- @return the integer value
- */
- #define JSAValueToInt(v) JSAEnvObj->vtoiFct(JSAEnvObj,v)
-
- /**
- Store an integer value into the given JSAValue.
-
- @param v the JSAValue to receive the integer value
- @param i the integer value to store
- */
- #define JSAIntToValue(v,i) JSAEnvObj->itovFct(JSAEnvObj,i,v)
-
- /**
- Retrieve the value as a boolean quantity (zero or nonzero). Automatic conversion
- to the value is applied according to Javascript rules if necessary.
- @param v the JSAValue to convert
- @return the boolean value
- */
- #define JSAValueToBool(v) JSAEnvObj->vtobFct(JSAEnvObj,v)
-
- /**
- Store an boolean value into the given JSAValue.
-
- @param v the JSAValue to receive the boolean value (zero or nonzero)
- @param b the boolean value (zero or nonzero) to store
- */
- #define JSABoolToValue(v,b) JSAEnvObj->btovFct(JSAEnvObj,b,v)
-
- /**
- Retrieve the value as a zero terminated ASCII string. Automatic conversion
- to the value is applied according to Javascript rules if necessary.
- @param v the JSAValue to convert
- @return the ASCII string
- */
- #define JSAValueToString(v) JSAEnvObj->vtosFct(JSAEnvObj,v)
-
- /**
- Store a zero terminated ASCII string value into the given JSAValue.
-
- @param v the JSAValue to receive the string
- @param s the string to store
- */
- #define JSAStringToValue(v,s) JSAEnvObj->stovFct(JSAEnvObj,s,v)
-
- /**
- Retrieve the value as an eight byte floating point value. Automatic conversion
- to the value is applied according to Javascript rules if necessary.
- @param v the JSAValue to convert
- @return the floating point value
- */
- #define JSAValueToDouble(v) JSAEnvObj->vtodFct(JSAEnvObj,v)
-
- /**
- Store an eight byte floating point value into the given JSAValue.
-
- @param v the JSAValue to receive the floating point value
- @param d the floating point value to store
- */
- #define JSADoubleToValue(v,d) JSAEnvObj->dtovFct(JSAEnvObj,d,v)
-
- /**
- Set the given value to undefined.
-
- @param v the JSAValue to be set to undefined.
- */
- #define JSAUndefinedToValue(v) JSAEnvObj->utovFct(JSAEnvObj,v)
-
- /**
- Register a function by name within the Javascript extension. Only registered functions can
- be called from within the Javascirpt extension modules. The function must be a JSANativeMethod.
- The location to register functions is within the JSAMain() function.
- @param n the function name. The name must follow Javascript naimg conventions.
- @param f the function itself (a JSANativeMethod)
- */
- #define JSARegisterFunction(n,f) JSAEnvObj->regFct(JSAEnvObj,n,f)
-
- /**
- Set a runtime error.
-
- @param text the error message as a zero terminated ASCII string
- */
- #define JSASetError(text) JSAEnvObj->errFct(JSAEnvObj,text)
-
- /**
- Evaluate a Javascript scriptlet. The scriptlet is executed within the current runtime scope
- of Javascript. An optional JSAValue may be supplied to receive the return value. The given
- timeout is the timeout in milliseconds to wait for the engine. If the timeout elapses before
- this call returns, a runtime error is generated. Supplying 0 means that the scriptlet is
- run asynchronously; the call returns immediately, and the return value location must be NULL.
- A value of -1 means to wait forever, which should be the default.
- @param text the scriptlet code to run
- @param retval the optional return value (may be NULL for no return value)
- @param timeout the timeout in milliseconds. 0 returns immediately, -1 waits forever.
- */
- #define JSAEval(text,retval,timeout) JSAEnvObj->evalFct(JSAEnvObj,text,retval,timeout)
-
- /**
- The structure supplied to allow for drawing inside a module.
- The Draw.getDrawInfo() method of the Extend Script SDK returns a long value which is really a
- pointer to a JSADrawInfo structure. The pointer may be retrieved by JSAValueToInt() and casted
- to a JSADrawInfo structure. The contents of the structure can be used to implement drawing
- in native code.
- */
- struct _JSADrawInfo
- {
- /// The device context. This is a DC handle on Windows or a GrafPtr pointer on the Mac.
- long context;
- /// The top left corner of the current drawing area.
- long left, top;
- /// The bottom right corner of the current drawing area.
- long right, bottom;
- };
-
- typedef struct _JSADrawInfo JSADrawInfo;
-
-
- /* ---------- Implementation ---------------- */
-
- extern JSAEnv *JSAEnvObj;
- extern void JSAEXPORT JSAEntry(JSAEnv *env);
-
- #define JSA_INIT \
- \
- JSAEnv *JSAEnvObj; \
- \
- void main() \
- { \
- } \
- \
- void JSAEXPORT JSAEntry(JSAEnv *env) \
- { \
- JSAEnvObj = env; \
- JSAMain(); \
- } \
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-